<template>
  <div class="viewcontainer" v-if="dataset && subDataSet">
    <hi-toolbar
      :source="dataset"
      :addOne="true"
      :disabled="dataset.isReadonly()"
      v-bind="toolbar"
      ref="dbtoolbar"
    ></hi-toolbar>
    <hi-form
      :dataSource="dataset"
      ref="detailForm"
      :model="dataset.curRecord"
      :disabled="dataset.isReadonly()"
      v-bind="form"
    ></hi-form>

    <hi-table
      ref="detailTable"
      :dataSource="subDataSet"
      v-bind="dataTable"
      :isEdit="!subDataSet.isReadonly()"
      :model="subDataSet.data"
    ></hi-table>
  </div>
</template>

<script>
import { HiForm, DataSetContainer, HiToolbar, HiTable, HiNumber } from "hi-ui";
import viewBase from "../../base";
import toolbar from "@/hiuiDefaultConfig/toolbar";
import purchaseOrderConfig from "./dataset/cashierpayList";
import purchaseOrderDetailConfig from "./dataset/cashierpayDetail";
import audittag from "@/views/component/audittag";
export default {
  name: "cashierpayDetail",
  extends: viewBase,
  components: { HiForm, HiToolbar, HiTable, HiNumber, audittag },

  data() {
    return {
      //数据集
      dataset: null,
      //数据集配置
      datasetCfg: purchaseOrderConfig,
      //从表数据集
      subDataSet: null,
      //从表数据集配置
      subDatasetCfg: purchaseOrderDetailConfig,

      //数据桥梁
      dataBridge: new Map(),
      //数据表格
      dataTable: {
        isEdit: true,
        hasSelection: true,
        hasRowNumber: true,
        columns: [
         
          {
            name: "FWORKNUMBER",
          },
          {
            name: "FPAYWAY",
          },
          {
            name: "FMONEY",
            props: {
              format: "￥0.00",
              precision: 2,
            },
          },
          {
            name: "FPAYMENT",
            props: {
              format: "￥0.00",
              precision: 2,
            },
          },
          {
            name: "FDIFFERMONEY",
            props: {
              format: "￥0.00",
              precision: 2,
            },
          },

          {
            name: "FBEGINTIME",
          },
          {
            name: "FENDTIME",
          },
          {
            name: "FNOTE",
          },
         /*  {
            name: "FUSERID",
          },

          {
            name: "FCREATEDATE",
          }, */
         
        ],
      },
      toolbar: toolbar,
      //表单配置
      form: {
        columnsTotal: 2,
        items: [
          {
            name: "FNUMBER",
          },
          {
            name: "FCASHIERID",
          },

          {
            name: "FCASHIERNAME",
          },

          {
            name: "FNOTE",
            colspan: 2,
            props: {
              type: "textarea",
              autosize: { minRows: 4, maxRows: 4 },
              maxlength: 200,
            },
          },
          {
            name: "FUSERID",
          },
          {
            name: "FCREATEDATE",
          },
          { element: audittag, name: "FAUDIT" },
        ],
      },
    };
  },
  model: {
    prop: "value",
    event: "valuechange",
  },
  props: {
    value: {
      type: Object,
    },
  },

  computed: {},
  watch: {},
  methods: {
    addDetail() {
      this.subDataSet.add({});
    },
  },
  mounted() {
    //创建主数据集
    this.dataset = this.$dsContainer.createDataSet(this.datasetCfg);
    this.dataset.on("dirtychange", (store, dirty) => {
      console.log("dataset" + dirty);
    });
    //创建从数据集
    this.subDataSet = this.$dsContainer.createDataSet(
      this.subDatasetCfg,
      this.dataset
    );
    //设置数据与组件的关系

    this.dataBridge.set(this.dataset, ["detailForm"]); //, "detailTable"
    this.flowConfig = { dataset: this.dataset };
    if (this.$route.query.id) {
      this.dataset.load({
        FID: this.$route.query.id,
      });
    }
  },
};
</script>
<style rel="stylesheet/scss" lang="scss" scope>
</style>

